home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / modula2 / 191 < prev    next >
Encoding:
Text File  |  1996-08-06  |  2.7 KB  |  71 lines

  1. Newsgroups: comp.lang.modula2
  2. Path: mcrcim.mcgill.edu!nyongwa!aliath
  3. From: aliath@nyongwa.montreal.qc.ca (Michel De Rosa)
  4. Subject: Re: Modula2 for C programmers?
  5. Message-ID: <DLxAHC.50q@nyongwa.montreal.qc.ca>
  6. Organization: Radio Free Nyongwa, Montreal (Qc), Canada
  7. Date: Mon, 29 Jan 1996 03:17:35 GMT
  8. References: <erico-1801961940460001@infinitehell.cnmat.berkeley.edu> <4dqusf$d7k@weck.brokersys.com> <DLIGLJ.FDE@nyongwa.montreal.qc.ca> <4du11j$l31@weck.brokersys.com>
  9. X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
  10.  
  11. jguthrie@brokersys.com wrote:
  12. : Michel De Rosa (aliath@nyongwa.montreal.qc.ca) wrote:
  13. : : [...]
  14. : : and/or/xor etc.. it's always been possible to do these, using the set
  15. : : operators.. first coerce to a BITSET...
  16. : Please don't talk down to me.
  17.  
  18. Sorry it wasn't my intention to do so..
  19.  
  20. : I know how to manipulate bitsets, but do WHAT to a BITSET?
  21.  
  22. Well other posts have, i hope, already cleared that up..
  23.  
  24. : As far as I know, NONE of the M2 compilers I have ever used allow me
  25. : to convert between any kind of number and any kind of set.
  26.  
  27. Again it may be only due to the fact that you weren't aware of the
  28. type-coercion facility..
  29.  
  30. I've used a number of different compilers, Logitech v3 (pc/dos), JPI
  31. TopSpeed (pc/dos), gpm-pc (again pc/dos), and an old pim2-based compiler
  32. for VAX/VMS.. they've all allowed this sort of coercion, with some caveats,
  33. mainly some of them would have restrictions, on a size of a set (the same
  34. with as a cardinal), and some wouldn't allow coercing from<->to a variable
  35. of a different size (say a bitset to a char)..
  36.  
  37. : I know that that isn't mentioned anywhere in PIM3C.
  38.  
  39. I've been at m2 for a long time (i mean real long time).. i honestly can't
  40. say how or when i first became aware of the facility.. i know it's in Pim4,
  41. because i recently had occasion to look it up..
  42.  
  43. I do use the term coercion, rather than casting, because there's a
  44. difference.. the way pim4 documents the facility, absolutely no
  45. interpretation of the bits is made.. we're forcing (coercing) the compiler
  46. to treat the expression, as if it was of a different type.
  47.  
  48. My understanding of type-casting, suggests that there's a minimum of
  49. interpretation being done, an attempt is made to preserve the value being
  50. cast to another type. That is assuming we have a short-integer type,
  51. than:
  52.  
  53.  si : SHORTINT;
  54.  i  : INTEGER;
  55.  ...
  56.    si := -1;              (* On intel this maps to  FFh *)
  57.    (* cast si to i *)
  58.    ... at this point i should be -1 , or FFFFh...
  59.  
  60. With type-coercion, we'd likely get a positive value (always assuming
  61. the compiler let's us cast/coerce between different bit-sizes).
  62.  
  63.    si := -1;
  64.    i := INTEGER(si);      (* we now have  00FFh *)
  65.  
  66.  
  67. Michel De Rosa
  68. Aliath@Nyongwa.montreal.qc.ca
  69.